# 0
# while,if

# 1
# break能否跳过else语句???

# 2
try:
    print('abc')
except:
    print('def')
else:
    print('ghi')
finally:
    print('jkl')


# 3
# 这样就好了

# if 'f' in locals():
#     # 如果文件对象变量存在当前局部变量符号表,说明打开成功
#     f.close()

# 4
# with可以在异常时关闭文件

# 5
# ???




def file_compare(file1, file2):
    with open(file1) as f1, open(file2) as f2:
        count = 0  # 统计行数
        differ = []  # 统计不一样的数量
        for line1 in f1:
            line2 = f2.readline()
            count += 1
            if line1 != line2:
                differ.append(count)
    return differ


file1 = 'opnMe.txt'
file2 = 'tst1.txt'

differ = file_compare(file1, file2)

if len(differ) == 0:
    print('俩文件一样')
else:
    print('俩文件公有[%d]处不同:' % len(differ))
    for each in differ:
        print('第[%d]行不一样' % each)
